<?php

/**
 * Loan form base class.
 *
 * @method Loan getObject() Returns the current form's model object
 *
 * @package    vmdai
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseLoanForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'remainder'       => new sfWidgetFormInputText(),
      'purpose'         => new sfWidgetFormInputText(),
      'list_type'       => new sfWidgetFormInputText(),
      'title'           => new sfWidgetFormInputText(),
      'money'           => new sfWidgetFormInputText(),
      'user_id'         => new sfWidgetFormInputText(),
      'is_day'          => new sfWidgetFormInputCheckbox(),
      'term_num'        => new sfWidgetFormInputText(),
      'money_rate'      => new sfWidgetFormInputText(),
      'end_time'        => new sfWidgetFormInputText(),
      'begin_time'      => new sfWidgetFormDateTime(),
      'service_fee'     => new sfWidgetFormInputText(),
      'cash'            => new sfWidgetFormInputCheckbox(),
      'status'          => new sfWidgetFormInputText(),
      'way_repayment'   => new sfWidgetFormInputText(),
      'has_dividend'    => new sfWidgetFormInputCheckbox(),
      'available_money' => new sfWidgetFormInputText(),
      'interest_sum'    => new sfWidgetFormInputText(),
      'blocked_money'   => new sfWidgetFormInputText(),
      'is_advance'      => new sfWidgetFormInputText(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'remainder'       => new sfValidatorNumber(),
      'purpose'         => new sfValidatorInteger(array('required' => false)),
      'list_type'       => new sfValidatorInteger(array('required' => false)),
      'title'           => new sfValidatorString(array('max_length' => 100)),
      'money'           => new sfValidatorNumber(),
      'user_id'         => new sfValidatorInteger(array('required' => false)),
      'is_day'          => new sfValidatorBoolean(array('required' => false)),
      'term_num'        => new sfValidatorInteger(array('required' => false)),
      'money_rate'      => new sfValidatorNumber(),
      'end_time'        => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'begin_time'      => new sfValidatorDateTime(array('required' => false)),
      'service_fee'     => new sfValidatorNumber(),
      'cash'            => new sfValidatorBoolean(array('required' => false)),
      'status'          => new sfValidatorInteger(array('required' => false)),
      'way_repayment'   => new sfValidatorInteger(array('required' => false)),
      'has_dividend'    => new sfValidatorBoolean(array('required' => false)),
      'available_money' => new sfValidatorNumber(array('required' => false)),
      'interest_sum'    => new sfValidatorNumber(array('required' => false)),
      'blocked_money'   => new sfValidatorNumber(array('required' => false)),
      'is_advance'      => new sfValidatorInteger(array('required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('loan[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Loan';
  }

}
